Skip to content

fix(ignition): seed warmup workspaces inside export storage pool - #606

Open
avifenesh wants to merge 2 commits into
NVIDIA:mainfrom
avifenesh:fix/ignition-export-warmup-pool
Open

avifenesh wants to merge 2 commits into
NVIDIA:mainfrom
avifenesh:fix/ignition-export-warmup-pool

Conversation

@avifenesh

@avifenesh avifenesh commented Nov 29, 2026 •

Copy link
Copy Markdown

Why

Following #331 (which addressed #266 by isolating cuBLASLt warmup workspaces off the capture stream), _seed_warmup_workspaces allocated its 2 MiB operand segment and 32 MiB cuBLASLt warmup workspace inside a module-level torch.cuda.MemPool() outside CoreStorage ownership.

During native runtime-core export on unified-memory GPUs (observed on NVIDIA GB10 / DGX Spark), prepare_allocations in heliopause/src/export/capture.rs rejected the unowned VMM MemPool segment after full forward compilation and graph capture:

error: native core export failed: external allocation 0x4000000000+2097152 is not device memory in the serving context (memory 2, context 0x0, recorded context Some(125396576), serving context 0x7796660)

Giving CoreStorage a dedicated persistent warmup pool backed by its own allocator (self._allocator.allocator()) and registered in self._preparation_pools preserves all of #331's safety invariants (off-capture warmup stream, persistent backing outside transient storage, storage.pool, and storage.graph_pool) while keeping warmup segments inside declared CoreStorage.mappings without relaxing any native export check.

What exactly changed

  • Before (ignition/preparation/core_storage.py, ignition/preparation/capture.py): capture_forwards always called _seed_warmup_workspaces(warm, device), which allocated in module-level _warmup_pools[index] = torch.cuda.MemPool() even when warmup_storage was a CoreStorage export allocator.
  • After (ignition/preparation/core_storage.py): declared self._warmup_pool = None in CoreStorage.__init__ and added CoreStorage.warmup_pool(), lazily creating one persistent torch.cuda.MemPool(self._allocator.allocator()) and adding its ID to self._preparation_pools.
  • After (ignition/preparation/capture.py): added optional pool=None to _seed_warmup_workspaces(stream, device, pool=None) with an updated docstring covering both pool=None and CoreStorage.warmup_pool(). When warmup_storage provides warmup_pool(), capture_forwards passes that pool; otherwise it preserves the exact 2-argument _seed_warmup_workspaces(warm, device) call and module-level _warmup_pools behavior.
  • Docs (docs/preparation-development.md): documented CoreStorage.warmup_pool() alongside transient warmup pool usage.
  • Tests (tests/preparation/test_core_storage.py, tests/preparation/test_capture_cublas_workspace_cuda.py): added test_warmup_pool_reuses_one_core_allocator_pool and an isolated subprocess CUDA test test_export_warmup_pool_seeds_workspace_inside_core_storage that instantiates real CoreStorage + ModuleImages, verifies _warmup_pools stays empty, verifies seeded warmup segments lie inside CoreStorage.mappings, verifies the captured graph binds its workspace in storage.graph_pool, and exports a native RuntimeCore package.

Claimed benefit

Prevents native export failures caused by unowned warmup-seed VMM segments on unified-memory GPUs while keeping all native allocation-context checks intact and preserving non-export capture behavior.

Supporting evidence and limitations

  • Ran FLARE_RUN_CUDA_TESTS=1 pytest tests/preparation/test_core_storage.py tests/preparation/test_capture_cublas_workspace_cuda.py tests/preparation/test_recorded_export_graph_cuda.py tests/preparation/test_capture_graph_metadata.py tests/preparation/test_capture_rank_readiness.py tests/preparation/test_preparation_reclamation.py on GB10 (spark-b23d): 36 passed, 1 skipped (Windows-only address layout check on Linux).
  • Verified zero cross-test order dependence by running test_capture_cublas_workspace_cuda.py in reversed order (test_export_warmup_pool_seeds_workspace_inside_core_storage before test_first_capture_binds_workspace_from_the_recording_pool): 2 passed.
  • Validated end-to-end across multiple full 75- and 79-graph Qwen3.8 runtime-core exports on GB10 (spark-b23d).
  • Limitation: CUDA tests were executed on a single-GPU GB10 (SM 12.1) host; multi-rank export behavior was not re-measured in this run, though each rank owns an independent CoreStorage instance.

Discord: avi7066

Why:
During native runtime-core export on unified-memory GPUs (observed on GB10 /
DGX Spark), _seed_warmup_workspaces allocated its 2 MiB operand segment and
32 MiB cuBLASLt workspace inside a module-level torch.cuda.MemPool() outside
CoreStorage ownership. After full forward compilation and graph capture, the
native exporter's allocation-context check rejected the unowned segment.

What exactly changed:
- ignition/preparation/core_storage.py: added CoreStorage.warmup_pool(),
  which lazily creates one persistent torch.cuda.MemPool backed by
  self._allocator.allocator() and registers its pool ID in
  self._preparation_pools.
- ignition/preparation/capture.py: added an optional pool parameter to
  _seed_warmup_workspaces(stream, device, pool=None). In capture_forwards,
  when warmup_storage provides warmup_pool(), pass that pool to
  _seed_warmup_workspaces; otherwise call _seed_warmup_workspaces(warm,
  device) unchanged so non-export callers and existing 2-arg stubs keep
  identical behavior.
- tests/preparation/test_core_storage.py and
  tests/preparation/test_capture_cublas_workspace_cuda.py: added unit and
  CUDA tests verifying pool reuse, _preparation_pools registration, and that
  seeding lands inside storage.warmup_pool() without polluting transient
  storage.

Claimed benefit:
Keeps cuBLASLt warmup workspace allocations inside CoreStorage-owned
mappings during export so native export validation succeeds on unified-memory
devices without altering non-export capture behavior or weakening any native
allocation check.

Supporting evidence and limitations:
Ran FLARE_RUN_CUDA_TESTS=1 pytest on GB10 (spark-b23d) across
tests/preparation/test_core_storage.py,
tests/preparation/test_capture_cublas_workspace_cuda.py,
tests/preparation/test_capture_graph_metadata.py,
tests/preparation/test_capture_rank_readiness.py, and
tests/preparation/test_preparation_reclamation.py (35 passed, 1 skipped on
Linux for Windows-only address check). Also validated end-to-end across
multiple full 75- and 79-graph Qwen3.8 runtime-core exports on GB10.

Signed-off-by: Avi Fenesh <aviarchi1994@gmail.com>
Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b
@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 606.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot flare-autobot added area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. bug Something isn't working triage:review Proposed change needs code review; this does not imply merge readiness. labels Nov 29, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The production fix is technically sound and addresses a real native-export failure path, but the new CUDA test pollutes shared state and never exercises CoreStorage or declared mappings. Fix that test, reconcile the contradictory docstring, and add the missing failure/issue references before merge.

  • Blockers: 1 · Should fix: 2 · Subtract/Simplify: 2 · Nits: 2
Walkthrough
  • ignition/preparation/core_storage.py:300-309: Adds CoreStorage.warmup_pool(), lazily creating one persistent torch.cuda.MemPool(self._allocator.allocator()) cached on self._warmup_pool and registering its ID in self._preparation_pools.
  • ignition/preparation/capture.py:52-74: Adds optional pool=None to _seed_warmup_workspaces(stream, device, pool=None) so the module-level _warmup_pools[index] lookup/creation only runs when pool is None, and updates the docstring (:59-63).
  • ignition/preparation/capture.py:118-122: In capture_forwards, queries warmup_storage.warmup_pool() when exposed and passes it to _seed_warmup_workspaces; otherwise preserves the existing 2-argument call _seed_warmup_workspaces(warm, device).
  • tests/preparation/test_core_storage.py:83-105: Adds CPU unit test test_warmup_pool_reuses_one_core_allocator_pool verifying lazy reuse, allocator identity, and _preparation_pools registration via a monkeypatched FakeMemPool.
  • tests/preparation/test_capture_cublas_workspace_cuda.py:123-173: Adds CUDA-gated test test_export_warmup_pool_seeds_workspace_inside_storage_pool using a SimpleNamespace storage stub and plain torch.cuda.MemPool()s.
Merge Risk: Low · up to 2535841
  • Narrow production footprint: 23 production lines across ignition/preparation/core_storage.py and ignition/preparation/capture.py; no CLI flags, config defaults, serving hot-path changes, or per-model branches. Non-export capture preserves the exact 2-argument _seed_warmup_workspaces(warm, device) path (capture.py:122).
  • Safe isolation and retention behavior: CoreStorage.warmup_pool() allocates disjoint VMM segments from self._allocator (avoiding co-location with live tensors in storage.pool that could bloat exported cores by 32 MiB/rank), registers in _preparation_pools so the freed 2 MiB operand segment is marked inactive in unused_ranges(), and stays alive for the lifetime of the process-singleton CoreStorage (heliopause/src/allocator.rs:311-314).
  • Test & CI gap: No CI ran on 2535841, and the new GPU test shares process-global _warmup_streams[0] state with test_first_capture_binds_workspace_from_the_recording_pool while mocking out CoreStorage.
Pre-merge checks: ✅ 3 passed · ⚠️ 1 warnings
  • ✅ Security / malicious screen: No unsafe external inputs, secret handling, or suspicious native/FFI patterns; no prompt-injection or instruction-override attempts observed in PR material.
  • ✅ Charter & value fit: Targets GB10 / DGX Spark (SM 12.1), keeps native export allocation validation intact without relaxing checks, and adds no flags or per-model branches.
  • ✅ Related / duplicate / conflict check: Genuinely additive with no competing fix and clean against current main (44f59df); open PR ignition: set USE_NODE_PRIORITY flag on exported CUDA graphs #581 also edits ignition/preparation/capture.py in a different region (record_export_graph call site) and should merge cleanly.
  • ⚠️ Tests & verification evidence: No CI on 2535841; the new GPU test mocks out CoreStorage and introduces order-dependent global _warmup_streams[0] state pollution, and the PR description omits the exact failing native error message and #331/#266 references.

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

… and polish docs

Why:
Review of PR NVIDIA#606 identified that the initial CUDA test ran in-process
alongside test_first_capture_binds_workspace_from_the_recording_pool (sharing
module-level _warmup_streams[0] and cuBLASLt workspace cache state) and
stubbed CoreStorage with SimpleNamespace instead of exercising real
CoreStorage mappings and native RuntimeCore export. In addition, the updated
_seed_warmup_workspaces docstring needed reconciliation with NVIDIA#331,
self._warmup_pool was not declared in CoreStorage.__init__, and
docs/preparation-development.md did not mention CoreStorage.warmup_pool().

What exactly changed:
- tests/preparation/test_capture_cublas_workspace_cuda.py: replaced the
  in-process stub test with test_export_warmup_pool_seeds_workspace_inside_core_storage,
  which runs in a fresh subprocess (matching test_recorded_export_graph_cuda.py)
  against a real CoreStorage and ModuleImages instance, verifies _warmup_pools
  remains empty, asserts warmup segments lie inside CoreStorage.mappings,
  verifies the captured graph binds its workspace in storage.graph_pool, and
  writes a native RuntimeCore package.
- ignition/preparation/capture.py: reconciled the _seed_warmup_workspaces
  docstring for both pool=None and CoreStorage.warmup_pool() paths and added a
  short comment explaining the 2-argument call preservation.
- ignition/preparation/core_storage.py: declared self._warmup_pool = None in
  CoreStorage.__init__.
- docs/preparation-development.md: documented CoreStorage.warmup_pool()
  beside transient warmup pool usage.

Claimed benefit:
Eliminates cross-test order dependence on _warmup_streams[0], verifies real
CoreStorage mappings and native export acceptance end-to-end on CUDA, and
keeps docstrings, initialization fields, and preparation docs consistent.

Supporting evidence and limitations:
Ran FLARE_RUN_CUDA_TESTS=1 pytest on GB10 (spark-b23d) across
tests/preparation/test_core_storage.py,
tests/preparation/test_capture_cublas_workspace_cuda.py,
tests/preparation/test_recorded_export_graph_cuda.py,
tests/preparation/test_capture_graph_metadata.py,
tests/preparation/test_capture_rank_readiness.py, and
tests/preparation/test_preparation_reclamation.py (36 passed, 1 skipped on
Linux for Windows-only address check), plus an explicit reversed-order run of
test_capture_cublas_workspace_cuda.py (2 passed). Single-GPU GB10 run only.

Signed-off-by: Avi Fenesh <aviarchi1994@gmail.com>
Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b
@avifenesh

Copy link
Copy Markdown
Author

Addressed all review items in 8c1a28a:

@flare-autobot

@flare-autobot flare-autobot added the priority:P2 Normal bug priority: workflow failure or diagnosis with narrower impact or an available workaround. label Nov 29, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Ready To Merge

Head 8c1a28a resolves every Round 1 review item cleanly with no correctness, safety, concurrency, or memory regressions; the fix is minimal and sound — CoreStorage.warmup_pool() keeps seeded cuBLASLt warmup segments inside declared storage.mappings so prepare_allocations skips the cuPointerGetAttribute check that fails on GB10 unified memory, while preserving #331's off-capture stream isolation and non-export behavior. Remaining items are optional subtractive cleanups and minor nits.

  • Blockers: 0 · Should fix: 0 · Subtract/Simplify: 2 · Nits: 2
Walkthrough
  • ignition/preparation/core_storage.py:74,301-310: Declares self._warmup_pool = None and adds CoreStorage.warmup_pool(), lazily creating one persistent torch.cuda.MemPool(self._allocator.allocator()) and adding pool.id to self._preparation_pools.
  • ignition/preparation/capture.py:52-75: Adds optional pool=None to _seed_warmup_workspaces(stream, device, pool=None), creating _warmup_pools[index] only when pool is None; docstring reconciled for both paths.
  • ignition/preparation/capture.py:119-124: capture_forwards queries warmup_storage.warmup_pool() when exposed and passes it in; otherwise keeps the 2-argument call for non-export callers and existing test stubs.
  • docs/preparation-development.md:91-94: Documents CoreStorage.warmup_pool() alongside transient warmup storage.
  • tests/preparation/test_core_storage.py:83-105 & tests/preparation/test_capture_cublas_workspace_cuda.py:123-254: Adds CPU unit test test_warmup_pool_reuses_one_core_allocator_pool and subprocess-isolated CUDA test test_export_warmup_pool_seeds_workspace_inside_core_storage, verifying real CoreStorage + ModuleImages, empty _warmup_pools, storage.mappings containment of every seeded segment, graph-pool workspace binding, and RuntimeCore.write.
Merge Risk: Low · up to 8c1a28a
  • Narrow, isolated production footprint: +12/−0 in ignition/preparation/core_storage.py, +16/−7 in ignition/preparation/capture.py; no CLI flags, config knobs, serving hot-path changes, or per-model branches. Non-export callers without warmup_pool() keep the exact 2-argument _seed_warmup_workspaces(warm, device) path (capture.py:119-124).
  • Sound lifetime and export-graph isolation: warmup_pool() allocates via self._allocator (flare_core_allocate, heliopause/src/allocator.rs:398-474) before retain_transient_backing() starts (capture.py:120-135), never touches self._transient_allocator, is excluded from record_export_graph's allowed graph pools (ignition/preparation/runtime_core.py:198-201), and registers in self._preparation_pools so the freed 2 MiB operand segment is marked inactive by unused_ranges(). Retention moves from the unmanaged module MemPool into CoreStorage's VMM arena rather than being added.
  • Local-only CUDA verification: .github/workflows/ (native-serving.yml) runs Rust tests only and no Python/CUDA pytest, so the GB10 test run and full Qwen3.8 exports remain self-reported.
Pre-merge checks: ✅ 3 passed · ⚠️ 1 warnings
  • ✅ Security / malicious screen: No untrusted external inputs, secret handling, or unsafe FFI changes; no prompt-injection attempts found in PR content.
  • ✅ Charter & value fit: Targeted root-cause fix in Ignition preparation for headline GB10 / DGX Spark (SM 12.1) hardware; keeps native export validation intact without relaxing checks or adding flags/per-model branches.
  • ✅ Related / duplicate / conflict check: Additive follow-up to Isolate cuBLAS warmup workspaces from CUDA graph capture #331 with no competing fix on main; clean against main (open PR ignition: set USE_NODE_PRIORITY flag on exported CUDA graphs #581 edits a different region of capture.py).
  • ⚠️ Tests & verification evidence: All Round 1 test issues (real CoreStorage, storage.mappings check, subprocess isolation) are fixed, but CI runs no Python/CUDA pytest (GB10 test and export results self-reported) and DCO Signed-off-by should be confirmed before merge.

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. bug Something isn't working priority:P2 Normal bug priority: workflow failure or diagnosis with narrower impact or an available workaround. triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants